home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Borland Plateform / TURBO PASCAL 1.5 for WIN / DOC.PAK / UTILS.DOC < prev    next >
Encoding:
Text File  |  1992-06-08  |  42.5 KB  |  1,167 lines

  1. =======================================================================
  2.                        Turbo Pascal Utilities
  3. =======================================================================
  4.  
  5. -----------------------------------------------------------------------
  6.                          Table of Contents
  7. -----------------------------------------------------------------------
  8.  1. Using TPUMOVER, the unit mover
  9.      A review of unit files
  10.      Using TPUMOVER
  11.  2. The Stand-Alone MAKE Utility
  12.      Creating makefiles
  13.       Comments
  14.       Explicit rules
  15.       Implicit rules
  16.       Command lists
  17.       Macros
  18.        Defined test macro ($d)
  19.        Base file name macro ($*)
  20.        Full file name macro ($<)
  21.        File name path macro ($:)
  22.        File name and extension macro ($.)
  23.        File name only macro ($&)
  24.       Directives
  25.      Using MAKE
  26.       The BUILTINS.MAK file
  27.       How MAKE searches for files
  28.       MAKE command-line options
  29.       MAKE error messages
  30.        Fatal errors
  31.        Errors
  32.  3. The TOUCH utility
  33.  4. The GREP utility
  34.      The GREP switches
  35.      How to search using GREP
  36.      Examples using GREP
  37. -----------------------------------------------------------------------
  38.  
  39. This file describes stand-alone utility programs that come with
  40. Turbo Pascal: TPUMOVER, MAKE, TOUCH, GREP.
  41.  
  42. ===================================
  43.  1. Using TPUMOVER, the Unit Mover
  44. ===================================
  45.  
  46. When you write units, you want to make them easily available to any
  47. programs that you develop. (Chapter mysteries, "Units and Related
  48. Mysteries," explains what a unit is and tells how to create your own
  49. units.) We'll now show you how to use TPUMOVER to remove seldom-used units
  50. from TURBO.TPL, and how to insert often-used units into TURBO.TPL.
  51.  
  52.  
  53.  A Review of Unit Files
  54. ========================
  55.  
  56. There are two types of unit files: .TPU files and .TPL files. When you
  57. compile a unit, Turbo Pascal puts the resulting object code in a .TPU
  58. (Turbo Pascal Unit) file, which always contains exactly one unit.
  59.  
  60. A .TPL (Turbo Pascal Library) file, on the other hand, can contain multiple
  61. units. For example, all the units that come on your Turbo Pascal disk are
  62. in the file TURBO.TPL. The file TURBO.TPL is currently the only library
  63. file Turbo Pascal will load units from.
  64.  
  65. You may have noticed, though, that you can use the standard Turbo Pascal
  66. units without giving a file name. That's because these units are stored in
  67. the Turbo Pascal standard unit file--TURBO.TPL on your distribution disk.
  68. Because the units are in that file, any program can use them without
  69. "knowing" their location.
  70.  
  71. Suppose you have a unit called TOOLS.TPU, and you use it in many different
  72. programs. Though adding Tools to TURBO.TPL takes up memory (TURBO.TPL is
  73. automatically loaded into memory by the compiler), adding it to the
  74. resident library makes "using" Tools faster because the unit is in memory
  75. instead of on disk.
  76.  
  77. There are five standard units already in TURBO.TPL: System, Overlay,
  78. Printer, Crt, and Dos.
  79.  
  80.  
  81.  Using TPUMOVER
  82. ================
  83.  
  84. You can use several command-line parameters that let you manipulate units
  85. quickly. The syntax for these parameters is
  86.  
  87.    TPUMOVER filename operations
  88.  
  89. where filename is either a .TPU file or a .TPL file,
  90.       and operations is an optional list of one or more of the following
  91.       commands:
  92.  
  93.          +unitname    Add a unit to the library.
  94.          -unitname    Delete a unit from the library.
  95.          *unitname    Extract a unit from the library.
  96.  
  97. If no operations are specified, TPUMOVER lists the units in the library
  98. file along with size and dependency information.
  99.  
  100.  
  101. =================================
  102.  2. The Stand-Alone MAKE Utility
  103. =================================
  104.  
  105. This section contains complete documentation for creating makefiles and
  106. using MAKE.
  107.  
  108.  
  109.  Creating Makefiles
  110. ====================
  111.  
  112. A makefile contains the definitions and relationships needed to help MAKE
  113. keep your program(s) up to date. You can create as many makefiles as you
  114. want and name them whatever you want. If you don't specify a makefile when
  115. you run MAKE (using the -f option), then MAKE looks for a file with the
  116. default name MAKEFILE.
  117.  
  118. You create a makefile with any ASCII text editor, such as Turbo Pascal's
  119. built-in interactive editor. All rules, definitions, and directives end
  120. with a carriage return; if a line is too long, you can continue it to the
  121. next line by placing a backslash (\) as the last character on the line.
  122.  
  123. Whitespace--spaces and tabs--is used to separate adjacent identifiers (such
  124. as dependencies) and to indent commands within a rule.
  125.  
  126. Creating a makefile is almost like writing a program--with definitions,
  127. commands, and directives. 
  128.  
  129.  Comments
  130. ----------
  131.  
  132. Comments begin with a number sign (#); the rest of the line following the #
  133. is ignored by MAKE. Comments can be placed anywhere and never have to start
  134. in a particular column.
  135.  
  136.  
  137.  Explicit Rules
  138. ----------------
  139.  
  140. Explicit rules take the form
  141.  
  142.    target [target ... ]: [source source ... ]
  143.       [command]
  144.       [command]
  145.       ...
  146.  
  147. where target is the file to be updated, source is a file upon which target
  148. depends, and command is any valid MS-DOS command (including invocation of
  149. .BAT files and execution of .COM and .EXE files).
  150.  
  151. Explicit rules define one or more target names, zero or more source files,
  152. and an optional list of commands to be performed. Target and source file
  153. names listed in explicit rules can contain normal MS-DOS drive and
  154. directory specifications, but they cannot contain wildcards.
  155.  
  156. Syntax here is important. target must be at the start of a line (in column
  157. 1), and each command must be indented (preceded by at least one space
  158. character or tab). As mentioned before, the backslash (\) can be used as a
  159. continuation character if the list of source files or a given command is
  160. too long for one line. Finally, both the source files and the commands are
  161. optional; it is possible to have an explicit rule consisting only of
  162.  
  163.    target [target ...] followed by a colon.
  164.  
  165. The idea behind an explicit rule is that the command or commands listed
  166. will create or update target, usually using the source files. When MAKE
  167. encounters an explicit rule, it first checks to see if any of the source
  168. files are target files elsewhere in the makefile. If so, those rules are
  169. evaluated first.
  170.  
  171. Once all the source files have been created or updated based on other
  172. explicit (or implicit) rules, MAKE checks to see if target exists. If not,
  173. each command is invoked in the order given. If target does exist, its time
  174. and date of last modification are compared against the time and date for
  175. each source. If any source has been modified more recently than target, the
  176. list of commands is executed.
  177.  
  178. A given file name can occur on the left side of an explicit rule only once
  179. in a given execution of MAKE.
  180.  
  181. Each command line in an explicit rule begins with whitespace. MAKE
  182. considers all lines following an explicit rule to be part of the command
  183. list for that rule, up to the next line that begins in column 1 (without
  184. any preceding whitespace) or up to the end of the file. Blank lines are
  185. ignored.
  186.  
  187. An explicit rule, with no command lines following it, is treated a little
  188. differently than an explicit rule with command lines.
  189.  
  190.    o If an explicit rule exists for a target with commands, the only files
  191.      that the target depends on are the ones listed in the explicit rule.
  192.  
  193.    o If an explicit rule has no commands, the targets depend on the files
  194.      given in the explicit rule, and they also depend on any file that
  195.      matches an implicit rule for the target(s).
  196.  
  197. Here are some examples of explicit rules from a makefile:
  198.  
  199.    myutil.obj: myutil.asm
  200.      tasm myutil.asm,myutil.obj;
  201.  
  202.    myapp.exe:  myapp.pas myglobal.tpu myutils.tpu
  203.      tpc myapp /Tc:\tp5\bin
  204.  
  205.    o The first explicit rule states that MYUTIL.OBJ depends upon
  206.      MYUTIL.ASM, and that MYUTIL.OBJ is created by executing the given
  207.      TASM command.
  208.  
  209.    o The second rule states that MYAPP.EXE depends upon MYAPP.PAS,
  210.      MYGLOBAL.TPU, and MYUTILS.TPU, and is created by the given TPC
  211.      command. (The /T plus path name in these examples will be explained
  212.      later.)
  213.  
  214. If you reorder the rules so that the one for MYAPP.EXE comes first,
  215. followed by the others, MAKE will recompile (or reassemble) only the files
  216. that it has to in order to update everything correctly. This is because a
  217. MAKE with no target on the command line will try to execute the first
  218. explicit rule it finds in the makefile.
  219.  
  220.  
  221.  Implicit Rules
  222. ----------------
  223.  
  224. MAKE also allows you to define implicit rules, which are generalizations of
  225. explicit rules. Here's an example to illustrate the relationship between
  226. the two types. Consider this explicit rule from the previous sample
  227. program:
  228.  
  229.    myutil.obj: myutil.asm
  230.      tasm myutil.asm,myutil.obj;
  231.  
  232. This rule is a common one, because it follows a general principle: An .OBJ
  233. file is dependent on the .ASM file with the same file name and is created
  234. by executing TASM (Turbo Assember). In fact, you might have a makefile
  235. where you have several (or even several dozen) explicit rules following
  236. this same format.
  237.  
  238. By redefining the explicit rule as an implicit rule, you can eliminate all
  239. the explicit rules of the same form. As an implicit rule, it would look
  240. like this:
  241.  
  242.    .asm.obj:
  243.      tasm $*.asm,$*.obj;
  244.  
  245. This rule means, "any file ending with .OBJ depends on the file with the
  246. same name that ends in .ASM, and the .OBJ file is created using the command
  247.  
  248.    tasm $*.asm,$*.obj
  249.  
  250. where $* represents the file's name with no extension." (The symbol $* is a
  251. special macro and is discussed in the next section.)
  252.  
  253. The syntax for an implicit rule follows:
  254.  
  255.    .source_extension.target_extension:
  256.      {command}
  257.      {command}
  258.      ...
  259.  
  260. Note the commands are optional and must be indented. The source_extension
  261. (which must begin in column 1) is the extension of the source file, that
  262. is, it applies to any file having the format
  263.  
  264.    fname.source_extension
  265.  
  266. Likewise, the target_extension refers to the the file
  267.  
  268.    fname.target_extension
  269.  
  270. where fname is the same for both files. In other words, this implicit rule
  271. replaces all explicit rules having the format
  272.  
  273.    fname.target_extension:fname.source_extension
  274.      [command]
  275.      [command]
  276.      ...
  277.  
  278. for any fname.
  279.  
  280. Implicit rules are used if no explicit rule for a given target can be found
  281. or if an explicit rule with no commands exists for the target.
  282.  
  283. The extension of the file name in question is used to determine which
  284. implicit rule to use. The implicit rule is applied if a file is found with
  285. the same name as the target, but with the mentioned source extension. For
  286. example, suppose you had a makefile (named MAKEFILE) whose contents were
  287.  
  288.    .asm.obj:
  289.      tasm $*.asm,$*.obj;
  290.  
  291. If you had an assembly language routine named RATIO.ASM that you wanted to
  292. compile to RATIO.OBJ, you could use the command
  293.  
  294.    make ratio.obj
  295.  
  296. MAKE would take RATIO.OBJ to be the target and create it by executing the
  297. command:
  298.  
  299.    tasm ratio.asm,ratio.obj;
  300.  
  301. Implicit rules are also used if an explicit rule is given with no commands.
  302. Suppose, as mentioned before, you had the following implicit rule at the
  303. start of your makefile:
  304.  
  305.    .pas.tpu:
  306.      tpc $<
  307.  
  308. You could then rewrite some explicit rules as follows:
  309.  
  310.    myglobal.tpu: myglobal.pas
  311.    myutils.tpu: myutils.pas myglobal.tpu myutil.obj
  312.  
  313. Since you don't have explicit information on how to create these .TPU
  314. files, MAKE applies the implicit rule defined earlier.
  315.  
  316. Several implicit rules can be written with the same target extension, but
  317. only one such rule can apply at a time. If more than one implicit rule
  318. exists for a given target extension, each rule is checked in the order the
  319. rules appear in the makefile, until all applicable rules are checked.
  320.  
  321. MAKE uses the first implicit rule that it discovers for a file with the
  322. source extension. Even if the commands of that rule fail, no more implicit
  323. rules are checked.
  324.  
  325. All lines following an implicit rule are considered to be part of the
  326. command list for the rule, up to the next line that begins without
  327. whitespace or to the end of the file. Blank lines are ignored. The syntax
  328. for a command line is provided later in this appendix.
  329.  
  330. MAKE does not know the full file name with an implicit rule, as it does
  331. with explicit rules. For that reason, special macros are provided with MAKE
  332. that allow you to include the name of the file being built by the rule.
  333.  
  334.  
  335.  Command Lists
  336. ---------------
  337.  
  338. Commands in a command list must be indented--that is, preceded by at least
  339. one space character or tab--and take the form
  340.  
  341.    [ prefix ... ] command_body
  342.  
  343. Each command line in a command list consists of an (optional) list of
  344. prefixes, followed by a single command body.
  345.  
  346. The prefixes allowed in a command modify the treatment of these commands by
  347. MAKE. The prefix is either the at (@) sign or a hyphen (-) followed
  348. immediately by a number.
  349.  
  350.    @   Keeps MAKE from displaying the command before executing it. The
  351.        display is hidden even if the -s option was not given on the MAKE
  352.        command line. This prefix applies only to the command on which it
  353.        appears.
  354.  
  355.    -num   Affects how MAKE treats exit codes. If a number (num) is
  356.           provided, then MAKE will abort processing only if the exit status
  357.           exceeds the number given. In this example, MAKE will abort only
  358.           if the exit status exceeds 4:
  359.  
  360.              -4 myprog sample.x
  361.  
  362.           If no -num prefix is given, MAKE checks the exit status for the
  363.           command. If the status is nonzero, MAKE will stop and delete the
  364.           current target file.
  365.  
  366.    -   With a hyphen but no number, MAKE will not check the exit status at
  367.        all. Regardless of what the exit status was, MAKE will continue.
  368.  
  369. The command body is treated exactly as if it were entered as a line to
  370. COMMAND.COM, with the exception that redirection and pipes are not
  371. supported. MAKE executes the following built-in commands by invoking a copy
  372. of COMMAND.COM to perform them:
  373.  
  374.    BREAK      CD      CHDIR      CLS      COPY
  375.    MD         MKDIR   PATH       PROMPT   REN
  376.    RENAME     SET     TIME       TYPE     VER
  377.    VERIFY     VOL
  378.  
  379. MAKE searches for any other command name using the MS-DOS search algorithm:
  380.  
  381.    o The current directory is searched first, followed by each directory
  382.      in the path.
  383.  
  384.    o In each directory, first a file with the extension .COM is checked,
  385.      then an .EXE file, and finally a .BAT.
  386.  
  387.    o If a .BAT file is found, a copy of COMMAND.COM is invoked to execute
  388.      the batch file.
  389.  
  390.  
  391. This command will cause MYPROG.PAS to be searched for, using the full
  392. search algorithm:
  393.  
  394.    tpc myprog.pas /$B+,R+,I+
  395.  
  396.  
  397.  Macros
  398. --------
  399.  
  400. Often certain commands, file names, or options are used again and again in
  401. your makefile. In an example earlier in this appendix, all the TPC commands
  402. used the switch /Tc:\tp5\bin, which means that the files TPC.CFG and
  403. TURBO.TPL are in the subdirectory C:\TP5\BIN. Suppose you wanted to switch
  404. to another subdirectory for those files; what would you do? You could go
  405. through and modify all the /T options, inserting the appropriate path name.
  406. Or, you could define a macro.
  407.  
  408. A macro is a name that represents some string of characters (letters and
  409. digits). A macro definition gives a macro name and the expansion text;
  410. thereafter, when MAKE encounters the macro name, it replaces the name with
  411. the expansion text.
  412.  
  413. Suppose you defined the following macro at the start of your makefile:
  414.  
  415.    TURBO=c:\tp5\bin
  416.  
  417. You've defined the macro TURBO, which is equivalent to the string
  418. c:\tp5\bin. You could now rewrite the makefile as follows:
  419.  
  420.    TURBO=c:\tp5\bin
  421.    myapp.exe:  myapp.pas myglobal.tpu myutils.tpu
  422.      tpc myapp /T$(TURBO)
  423.  
  424.    myutils.tpu: myutils.pas myglobal.tpu myutil.obj
  425.      tpc myutils /T$(TURBO)
  426.  
  427.  
  428. Everywhere the Turbo directory is specified, you use the macro invocation
  429. $(TURBO). When you run MAKE, $(TURBO) is replaced with its expansion text,
  430. c:\TP5.BIN. The result is the same set of commands you had before but with
  431. greater flexibility.
  432.  
  433. In fact, if you leave out the first line altogether, you can specify which 
  434. subdirectory you want each time you run MAKE, using the -D (Define) option:
  435.  
  436.    make -DTURBO=c:\tp5\project
  437.  
  438. Macro definitions take the form
  439.  
  440.    macro_name=expansion text
  441.  
  442. where macro_name is the name of a macro made up of a string of letters and
  443. digits with no whitespace in it, though you can have whitespace between
  444. macro_name and the equal sign (=). [expansion text] is any arbitrary string
  445. containing letters, digits, whitespace, and punctuation; it is ended by a
  446. carriage return.  Note that macros are case sensitive.  Thus the macro
  447. names Turbo, turbo and TURBO are all different.
  448.  
  449. If macro_name has previously been defined, either by a macro definition in
  450. the makefile or by the -D option on the MAKE command line, the new
  451. definition replaces the old.
  452.  
  453. Macros are invoked in your makefile with the format
  454.  
  455.    $(macro_name)
  456.  
  457. Macros in macros: Macros cannot be invoked on the left (macro_name) side of
  458. a macro definition. They can be used on the right (expansion text) side,
  459. but they are not expanded until the macro being defined is invoked. In
  460. other words, when a macro invocation is expanded, any macros embedded in
  461. its expansion text are also expanded.
  462.  
  463. MAKE comes with several special predefined macros built-in: $d, $*, $<, $:,
  464. $., and $&. The first is a defined test macro, used in the conditional
  465. directives !if and !elif; the others are file name macros, used in explicit
  466. and implicit rules. The various file name macros work in similar ways,
  467. expanding to some variation of the full path name of the file being built.
  468. In addition, the current SET environment strings are automatically loaded
  469. as macros, and the macro __MAKE__ is defined to be 1 (one).
  470.  
  471.  
  472.  Defined Test Macro ($d)
  473.  
  474. This macro expands to 1 if the given macro name is defined, or to 0 if it
  475. is not. The content of the macro's expansion text does not matter. This
  476. special macro is allowed only in !if and !elif directives. For example, if
  477. you wanted to modify your makefile so that it would use a particular Turbo
  478. Pascal directory if you didn't specify one, you could put this at the start
  479. of your makefile:
  480.  
  481.    !if !$d(TURBO)            # if TURBO is not defined
  482.    TURBO=c:\tp5\bin          # define it to C:\TP5\BIN
  483.    !endif
  484.  
  485. If you invoke MAKE with the command line
  486.  
  487.    make -DTURBO=c:\tp5\project
  488.  
  489. then TURBO is defined as c:\tp5\project. If, however, you just invoke MAKE
  490. by itself,
  491.  
  492.    make
  493.  
  494. then TURBO is defined as c:\tp5\bin, your "default" subdirectory.
  495.  
  496.  
  497.  Base File Name Macro ($*)
  498.  
  499. This macro is allowed in the commands for an explicit or an implicit rule.
  500. The macro expands to the file name being built, excluding any extension,
  501. like this:
  502.  
  503.    File name is A:\P\TESTFILE.PAS
  504.    $* expands to A:\P\TESTFILE
  505.  
  506. For example, you could modify the explicit MYAPP.EXE rule already given to
  507. look like this:
  508.  
  509.    myapp.exe:  myapp.pas myglobal.tpu myutils.tpu
  510.      tpc $* /T$(TURBO)
  511.  
  512.  
  513.  Full File Name Macro ($<)
  514.  
  515. The full file name macro ($<) is also used in the commands for an explicit
  516. or implicit rule. In an explicit rule, $< expands to the full target file
  517. name (including extension), like this:
  518.  
  519.    File name is A:\P\TESTFILE.PAS
  520.    $< expands to A:\P\TESTFILE.PAS
  521.  
  522. In an implicit rule, $< takes on the file name plus the source extension.
  523. For example, the previous implicit rule
  524.  
  525.    .asm.obj:
  526.      tasm $*.asm,$*.obj;
  527.  
  528. can be rewritten as
  529.  
  530.    .asm.obj:
  531.       tasm $<,$*.obj;
  532.  
  533.  
  534.  File Name Path Macro ($:)
  535.  
  536. This macro expands to the path name (without the file name), like this:
  537.  
  538.    File name is A:\P\TESTFILE.PAS
  539.    $: expands to A:\P\
  540.  
  541.  
  542.  File Name and Extension Macro ($.)
  543.  
  544. This macro expands to the file name, with extension, like this:
  545.  
  546.    File name is A:\P\TESTFILE.PAS
  547.    $. expands to TESTFILE.PAS
  548.  
  549.  
  550.  File Name Only Macro ($&)
  551.  
  552. This macro expands to the file name only, without path or extension, like
  553. this:
  554.  
  555.    File name is A:\P\TESTFILE.PAS
  556.    $& expands to TESTFILE
  557.  
  558.  
  559.  Directives
  560. ------------
  561.  
  562. The version of MAKE bundled with Turbo Pascal allows something that other
  563. versions of MAKE don't: conditional directives similiar to those allowed
  564. for Turbo Pascal. You can use these directives to include other makefiles,
  565. to make the rules and commands conditional, to print out error messages,
  566. and to "undefine" macros.
  567.  
  568. Directives in a makefile begin with an exclamation point (!). Here is the
  569. complete list of MAKE directives:
  570.  
  571.    !include
  572.    !if
  573.    !else
  574.    !elif
  575.    !endif
  576.    !error
  577.    !undef
  578.  
  579. A file-inclusion directive (!include) specifies a file to be included into
  580. the makefile for interpretation at the point of the directive. It takes the
  581. following form:
  582.  
  583.    !include "filename"
  584.  
  585. or
  586.  
  587.    !include <filename>
  588.  
  589. These directives can be nested arbitrarily deep. If an include directive
  590. attempts to include a file that has already been included in some outer
  591. level of nesting (so that a nesting loop is about to start), the inner
  592. include directive is rejected as an error.
  593.  
  594. Conditional directives (!if, !elif, !else, and !endif) give a programmer a
  595. measure of flexibility in constructing makefiles. Rules and macros can be
  596. "conditionalized" so that a command-line macro definition (using the -D
  597. option) can enable or disable sections of the makefile.
  598.  
  599. The format of these directives parallels, but is more extensive than, the
  600. conditional directives allowed by Turbo Pascal:
  601.  
  602.    !if expression
  603.      [ lines ]
  604.    !endif
  605.  
  606.    !if expression
  607.      [ lines ]
  608.    !else
  609.      [ lines ]
  610.    !endif
  611.  
  612.    !if expression
  613.      [ lines ]
  614.    !elif expression
  615.      [ lines ]
  616.    !endif
  617.  
  618. The conditional directives form a group, with at least an !if directive
  619. beginning the group and an !endif directive closing the group.
  620.  
  621. The expression allowed in an !if or an !elif directive uses a syntax
  622. similar to that found in the C programming language. The expression is
  623. evaluated as a simple 32-bit signed integer expression.
  624.  
  625. Numbers can be entered as decimal, octal, or hexadecimal constants. For
  626. example, these are legal constants in an expression:
  627.  
  628.    4536       # decimal constant
  629.    0677       # octal constant (note the leading zero)
  630.    0x23aF     # hexadecimal constant
  631.  
  632. and any of the following unary operators:
  633.  
  634.    -     negation
  635.    ~     bit complement
  636.    !     logical not
  637.  
  638. An expression can use any of the following binary operators:
  639.  
  640.    +     addition
  641.    -     subtraction
  642.    *     multiplication
  643.    /     division
  644.    %     remainder
  645.    >>    right shift
  646.    <<    left shift
  647.    &     bitwise and
  648.    |     bitwise or
  649.    ^     bitwise exclusive or
  650.    &&    logical and
  651.    ||    logical or
  652.    >     greater than
  653.    <     less than
  654.    >=    greater than or equal to
  655.    <=    less than or equal to
  656.    ==    equality
  657.    !=    inequality
  658.  
  659. An expression can contain the following ternary operator:
  660.  
  661.    ? :   The operand before the ? is treated as a test.
  662.  
  663.          If the value of that operand is nonzero, then the second
  664.          operand (the part between the ? and the colon) is the
  665.          result. If the value of the first operand is zero, the
  666.          value of the result is the value of the third operand
  667.          (the part after the :).
  668.  
  669. Parentheses can be used to group operands in an expression. In the absence
  670. of parentheses, binary operators are grouped according to the same
  671. precedence given in the C language.
  672.  
  673. Grouping is from left to right for operators of equal precedence, except
  674. for the ternary operator (? :), which is right to left.
  675.  
  676. Macros can be invoked within an expression, and the special macro $d() is
  677. recognized. After all macros have been expanded, the expression must have
  678. proper syntax. Any words in the expanded expression are treated as errors.
  679.  
  680. The error directive (!error) causes MAKE to stop and print a fatal
  681. diagnostic containing the text after !error. It takes the format
  682.  
  683.    !error [any_text]
  684.  
  685. This directive is designed to be included in conditional directives to
  686. allow a user-defined abort condition. 
  687.  
  688. The undefine directive (!undef) causes any definition for the named macro
  689. to be forgotten. If the macro is currently undefined, this directive has no
  690. effect. 
  691.  
  692.  Using MAKE
  693. ============
  694.  
  695. You now know a lot about how to write makefiles; now's the time to learn
  696. how to use them with MAKE. The simplest way to use MAKE is to type the
  697. command
  698.  
  699.    MAKE
  700.  
  701. at the MS-DOS prompt. MAKE then looks for MAKEFILE; if it can't find it, it
  702. looks for MAKEFILE.MAK; if it can't find that, it halts with an error
  703. message.
  704.  
  705. You can specify a file with the -f option:
  706.  
  707.    MAKE -fstars.mak
  708.  
  709. The general syntax for MAKE is
  710.  
  711.    make option option ... target target ...
  712.  
  713. where option is a MAKE option (discussed later) and target is the name of a
  714. target file to be handled by explicit rules.
  715.  
  716. If the command line does not include any target names, MAKE uses the first
  717. target file mentioned in an explicit rule. If one or more targets are
  718. mentioned on the command line, they will be built as necessary.
  719.  
  720. Here are some more examples of MAKE command lines:
  721.  
  722.    make -n -fstars.mak
  723.    make -s
  724.    make -Iinclude -DTURBO=c:\tp5\project
  725.  
  726.  
  727.  The BUILTINS.MAK File
  728. -----------------------
  729.  
  730. As you become familiar with MAKE, you will find that there are macros and
  731. rules (usually implicit ones) that you use again and again. You've got
  732. three ways of handling them. First, you can put them in every makefile you
  733. create. Second, you can put them all in one file and use the !include
  734. directive in each makefile you create. Third, you can put them all in a
  735. file named BUILTINS.MAK.
  736.  
  737. Each time you run MAKE, it looks for a file named BUILTINS.MAK; if it finds
  738. the file, MAKE reads it in before handling MAKEFILE (or whichever makefile
  739. you want it to process).
  740.  
  741. The BUILTINS.MAK file is intended for any rules (usually implicit rules) or
  742. macros that will be commonly used in files anywhere on your computer.
  743.  
  744. There is no requirement that any BUILTINS.MAK file exist. If MAKE finds a
  745. BUILTINS.MAK file, it interprets that file first. If MAKE cannot find a
  746. BUILTINS.MAK file, it proceeds directly to interpreting MAKEFILE (or
  747. whatever makefile you specify).
  748.  
  749.  
  750.  How MAKE Searches for Files
  751. -----------------------------
  752.  
  753. MAKE will search for BUILTINS.MAK in the current directory or in the exec
  754. directory if your computer is running under DOS 3.x. You should place this
  755. file in the same directory as the MAKE.EXE file.
  756.  
  757. MAKE always searches for the makefile in the current directory only. This
  758. file contains the rules for the particular executable program file being
  759. built. The two files have identical syntax rules.
  760.  
  761. MAKE also searches for any !include files in the current directory. If you
  762. use the -I (Include) option, it will also search in the specified
  763. directory.
  764.  
  765.  
  766.  MAKE Command-Line Options
  767. ---------------------------
  768.  
  769.    -Didentifier   Defines the named identifier to the string consisting of
  770.                   the single character 1.
  771.  
  772.    -Diden=string  Defines the named identifier iden to the string after
  773.                   the equal sign. The string cannot contain any spaces or
  774.                   tabs.
  775.  
  776.    -Idirectory    MAKE will search for include files in the indicated
  777.                   directory (as well as in the current directory).
  778.  
  779.    -Uidentifier   Undefines any previous definitions of the named
  780.                   identifier.
  781.  
  782.    -s             Normally, MAKE prints each command as it is about to be
  783.                   executed. With the -s option, no commands are printed
  784.                   before execution.
  785.  
  786.    -n             Causes MAKE to print the commands, but not actually
  787.                   perform them. This is useful for debugging a makefile.
  788.  
  789.    -ffilename     Uses filename as the MAKE file. If filename does not
  790.                   exist and no extension is given, tries filename.MAK.
  791.  
  792.    -? or -h       Prints help message.
  793.  
  794.  
  795.  MAKE Error Messages
  796. ---------------------
  797.  
  798.  Fatal Errors
  799.  
  800. Don't know how to make XXXXXXXX
  801.    This message is issued when MAKE encounters a nonexistent file name in
  802.    the build sequence, and no rule exists that would allow the file name to
  803.    be built.
  804.  
  805. Error directive: XXXX
  806.    This message is issued when MAKE processes an #error directive in the
  807.    source file. The text of the directive is displayed in the message.
  808.  
  809. Incorrect command line argument: XXX
  810.    This error occurs if MAKE is executed with incorrect command-line
  811.    arguments.
  812.  
  813. Not enough memory
  814.    This error occurs when the total working storage has been exhausted. You
  815.    should try this on a machine with more memory. If you already have 640K
  816.    in your machine, you may have to simplify the source file.
  817.  
  818. Unable to execute command
  819.    This message is issued after attempting to execute a command. This could
  820.    be a result of the command file not being found, or because it was
  821.    misspelled. A less likely possibility is that the command exists but is
  822.    somehow corrupted.
  823.  
  824. Unable to open makefile
  825.    This message is issued when the current directory does not contain a
  826.    file named MAKEFILE.
  827.  
  828.  
  829.  Errors
  830.  
  831. Bad file name format in include statement
  832.    Include file names must be surrounded by quotes or angle brackets. The
  833.    file name was missing the opening quote or angle bracket.
  834.  
  835. Bad undef statement syntax
  836.    An !undef statement must contain a single identifier and nothing else as
  837.    the body of the statement.
  838.  
  839. Character constant too long
  840.    Character constants can be only one or two characters long.
  841.  
  842. Command arguments too long
  843.    The arguments to a command executed by MAKE were more than 127
  844.    characters--a limit imposed by DOS.
  845.  
  846. Command syntax error
  847.    This message occurs if
  848.  
  849.       o the first rule line of the makefile contained any leading
  850.         whitespace.
  851.  
  852.       o an implicit rule did not consist of .ext.ext:.
  853.  
  854.       o an explicit rule did not contain a name before the : character.
  855.  
  856.       o a macro definition did not contain a name before the = character.
  857.  
  858. Division by zero
  859.    A divide or remainder in an !if statement has a zero divisor.
  860.  
  861. Expression syntax error in !if statement
  862.    The expression in an !if statement is badly formed--it contains a
  863.    mismatched parenthesis, an extra or missing operator, or a missing or
  864.    extra constant.
  865.  
  866. File name too long
  867.    The file name given in an !include directive was too long for MAKE to
  868.    process. File path names in MS-DOS must be no more than 78 characters
  869.    long.
  870.  
  871. Illegal character in constant expression X
  872.    MAKE encountered some character not allowed in a constant expression. If
  873.    the character is a letter, this indicates a (probably) misspelled
  874.    identifier.
  875.  
  876. Illegal octal digit
  877.    An octal constant was found containing a digit of 8 or 9.
  878.  
  879. Macro expansion too long
  880.    A macro cannot expand to more than 4096 characters. This error often
  881.    occurs if a macro recursively expands itself. A macro cannot legally
  882.    expand to itself.
  883.  
  884. Misplaced elif statement
  885.    An !elif directive was encountered without any matching !if directive.
  886.  
  887. Misplaced else statement
  888.    An !else directive was encountered without any matching !if directive.
  889.  
  890. Misplaced endif statement
  891.    An !endif directive was encountered without any matching !if directive.
  892.  
  893. No file name ending
  894.    The file name in an include statement was missing the correct closing
  895.    quote or angle bracket.
  896.  
  897. Redefinition of target XXXXXXXX
  898.    The named file occurs on the left-hand side of more than one explicit
  899.    rule.
  900.  
  901. Unable to open include file XXXXXXXXX.XXX
  902.    The named file could not be found. This could also be caused if an
  903.    include file included itself. Check whether the named file exists.
  904.  
  905. Unexpected end of file in conditional started on line #
  906.    The source file ended before MAKE encountered an !endif. The !endif was
  907.    either missing or misspelled.
  908.  
  909. Unknown preprocessor statement
  910.    A ! character was encountered at the beginning of a line, and the
  911.    statement name following was not error, undef, if, elif, include, else,
  912.    or endif.
  913.  
  914.  
  915. ======================
  916.  3. The TOUCH Utility
  917. ======================
  918.  
  919. There are times when you want to force a particular target file to be
  920. recompiled or rebuilt, even though no changes have been made to its
  921. sources. One way to do this is to use the TOUCH utility included with Turbo
  922. Pascal. TOUCH changes the date and time of one or more files to the current
  923. date and time, making it "newer" than the files that depend on it.
  924.  
  925. To force a target file to be rebuilt, "touch" one of the files that target
  926. depends on. To touch a file (or files), enter
  927.  
  928.    touch filename [ filename ... ]
  929.  
  930. at the DOS prompt. TOUCH will then update the file's creation date(s).
  931.  
  932. Once you do this, you can invoke MAKE to rebuild the touched target
  933. file(s).
  934.  
  935.  
  936. =====================
  937.  4. The GREP Utility
  938. =====================
  939.  
  940. GREP is a powerful search utility that can look for text in several files
  941. at once. 
  942.  
  943. The command-line syntax for GREP follows:
  944.  
  945.    GREP [options] searchstring [filespec ... ]
  946.  
  947. where options consists of one or more single characters preceded by a
  948. hyphen, searchstring defines the pattern to search for, and filespec is the
  949. file specification. filespec tells GREP which files (or groups of files) to
  950. search; it can be an explicit file name or a generic file name
  951. incorporating the DOS wildcards (? and *). You can also enter a path as
  952. part of filespec; if you use filespec without a path, GREP only searches
  953. the current directory. If you don't specify filespec, input to GREP must be
  954. specified by redirecting stdin or piping.
  955.  
  956.  
  957.  The GREP Switches
  958. ===================
  959.  
  960. In the command line, options are one or more single characters preceded by
  961. a hyphen (-). Each individual character is a switch that you can turn on or
  962. off: type the plus symbol (+) after a character to turn the option on, or
  963. type a hyphen (-) after the character to turn the option off.
  964.  
  965. The default is on (the + is implied): for example, -R means the same thing
  966. as -R+. You can list multiple options individually like this: -I -D -L). Or
  967. you can combine them like this: -ILD or -IL -D, and so on). It's all the
  968. same to GREP.
  969.  
  970. Here is a list of the switches and their meanings:
  971.  
  972.    -C   Count only: Only a count of matching lines is printed. For each
  973.         file that contains at least one matching line, GREP prints the file
  974.         name and a count of the number of matching lines. Matching lines
  975.         are not printed.
  976.  
  977.    -D   Directories: For each filespec specified on the command line, GREP
  978.         searches for all files that match the file specification, both in
  979.         the directory specified and in all subdirectories below the
  980.         specified directory. If you give a filespec without a path, GREP
  981.         assumes the files are in the current directory.
  982.  
  983.    -I   Ignore case: GREP ignores upper/lowercase differences (case
  984.         folding). GREP treats all letters a-z as being identical to the
  985.         corresponding letters A-Z in all situations.
  986.  
  987.    -L   List match files: Only the name of each file containing a match is
  988.         printed. After GREP finds a match, it prints the file name and
  989.         processing immediately moves on to the next file.
  990.  
  991.    -N   Numbers: Each matching line that GREP prints is preceded by its
  992.         line number.
  993.  
  994.    -O   UNIX output format: Changes the output format of matching lines to
  995.         support more easily the UNIX style of command-line piping. All
  996.         lines of output are preceded by the name of the file which
  997.         contained the matching line.
  998.  
  999.    -R   Regular expression search: The text defined by searchstring is
  1000.         treated as a regular expression instead of as a literal string.
  1001.  
  1002.    -U   Update options: GREP will combine the options given on the command
  1003.         line with its default options and write these to the GREP.COM file
  1004.         as the new defaults. (In other words, GREP is self-configuring.)
  1005.         This option allows you to tailor the default option settings to
  1006.         your own taste.
  1007.  
  1008.    -V   Non-match: Only non-matching lines are printed. Only lines that do
  1009.         not contain the search string are considered to be non-matching
  1010.         lines.
  1011.  
  1012.    -W   Word search: Text found which matches the regular expression will
  1013.         be considered a match only if the character immediately preceding
  1014.         and following cannot be part of a word. The default word character
  1015.         set includes A-Z, 9-0, and the underbar (_). An alternate form of
  1016.         this option allows you to specify the set of legal word characters.
  1017.         Its form is -W[set], where set is any valid regular expression set
  1018.         definition. If alphabetic characters are used to define the set,
  1019.         the set will automatically be defined to contain both the upper and
  1020.         lower case values for each letter in the set, regardless of how it
  1021.         is typed, even if the search is case-sensitive. If the -W option is
  1022.         used in combination with the -U option, the new set of legal
  1023.         characters is saved as the default set.
  1024.  
  1025.    -Z   Verbose: GREP prints the file name of every file searched. Each
  1026.         matching line is preceded by its line number. A count of matching
  1027.         lines in each file is given, even if the count is zero.
  1028.  
  1029. Several of these options are in direct conflict with each other. In these
  1030. cases, the following order applies (the first one is the one that takes
  1031. precedence):
  1032.  
  1033.    -Z   -L   -C   -N
  1034.  
  1035. Each occurrence of an option overrides the previous definition: Its state
  1036. reflects the way you last set it. At any given time, each option can only
  1037. be on or off.
  1038.  
  1039. You can install your preferred default setting for each option in GREP.COM
  1040. with the -U option. For example, if you want GREP to always do a verbose
  1041. search (-Z on), you can install it with the following command:
  1042.  
  1043.    GREP -U -Z
  1044.  
  1045.  
  1046.  How to Search Using GREP
  1047. ==========================
  1048.  
  1049. The value of searchstring defines the pattern GREP will search for.  A
  1050. search string can be either a (via the -R switch) or a literal string. In
  1051. regular expressions, operators govern the search; literal strings have no
  1052. operators.
  1053.  
  1054. You can enclose the search string in quotation marks to prevent spaces and
  1055. tabs from being treated as delimiters. Matches will not cross line
  1056. boundaries (a match must be contained in a single line).
  1057.  
  1058. When the -R switch is used, the search string is treated as a regular
  1059. expression (as opposed to a literal expression), and the following symbols
  1060. take on special meanings:
  1061.  
  1062.    ^   A caret at the start of the expression matches the start
  1063.        of a line.
  1064.  
  1065.    $   A dollar sign at the end of the expression matches the end
  1066.        of a line.
  1067.  
  1068.    .   A period matches any character.
  1069.  
  1070.    *   An expression followed by an asterisk wildcard matches
  1071.        zero or more occurrences of that expression: fo* matches
  1072.        f, fo, foo, etc.
  1073.  
  1074.    +   An expression followed by a plus sign matches one or more
  1075.        occurrences of that expression: fo+ matches fo, foo, etc.,
  1076.        but not f.
  1077.  
  1078.    []  A string enclosed in brackets matches any character in
  1079.        that string, but no others. If the first character in the
  1080.        string is a caret (^), the expression matches any
  1081.        character except the characters in the string. For
  1082.        example, [xyz] matches x, y, and z, while [^xyz] matches a
  1083.        and b, but not x or y. A range of characters can be
  1084.        specified by two characters separated by a hyphen (-).
  1085.        These can be combined to form expressions like [?a-bd-z]
  1086.        to match ? and any letter except c.
  1087.  
  1088.    \   The backslash "escape character" tells GREP to seach for
  1089.        the literal character that follows it. For example, \.
  1090.        matches a period instead of any character.
  1091.  
  1092.    Note: Four characters (?, +, *, and .) do not have any special
  1093.    meaning when used in a set. The character ^ is only treated
  1094.    specially if it immediately follows the beginning of the set
  1095.    (that is, immediately after the [).
  1096.  
  1097. Any ordinary character not mentioned in this list matches that character. A
  1098. concatenation of regular expressions is a regular expression.
  1099.  
  1100.  
  1101.  Examples Using GREP
  1102. =====================
  1103.  
  1104. The following examples assume all options default to off.
  1105.  
  1106. ----------------------------------------------------------------------
  1107.  
  1108. Search String   grep -n function dirdemo.pas
  1109.  
  1110. Finds       File DIRDEMO.PAS:
  1111.             46      LessFunc = function(X, Y: DirPtr): Boolean;
  1112.             55      function NumStr(N, D: Integer): string;
  1113.             68      function LessName(X, Y: DirPtr): Boolean;
  1114.             73      function LessSize(X, Y: DirPtr): Boolean;
  1115.             78      function LessTime(X, Y: DirPtr): Boolean;
  1116.  
  1117. Remarks     Finds all functions in the file DIRDEMO.PAS. The -N
  1118.             tells GREP to precede each matched line with its line
  1119.             number.
  1120.  
  1121. ----------------------------------------------------------------------
  1122.  
  1123. Search String   grep {\$ dirdemo.pas
  1124.  
  1125. Finds       File DIRDEMO.PAS:
  1126.             {$I-,S-}
  1127.             {$M 8192,8192,655360}
  1128.             {$F+}
  1129.             {$F-}
  1130.  
  1131. Remarks     Finds all compiler directives in DIRDEMO.PAS. The \
  1132.             (backslash) preceding the $ is necessary. Without it,
  1133.             the $ would indicate the end of the line. All lines
  1134.             with { (curly bracket) as the last character would
  1135.             match this pattern and be printed out.
  1136.  
  1137. ----------------------------------------------------------------------
  1138.  
  1139. Search String   grep -i "^ *function.*).*real" *.pas
  1140.  
  1141. Finds       File MCPARSER.PAS:
  1142.             function CellValue(Col, Row: Word): Real;
  1143.             function Parse(S: string; var Att: Word): Real;
  1144.  
  1145. Remarks     Finds all lines that begin with zero or more spaces
  1146.             followed by the word function, followed by any string
  1147.             of zero or more characters, followed by a
  1148.             parenthesis, followed by another string of zero or
  1149.             more characters, followed by the word Real, and
  1150.             ignores case. The net effect is to search for all
  1151.             functions returning a Real. See if you can think of
  1152.             other ways to do this.
  1153.  
  1154.             The double quotes are necessary because of the space
  1155.             in the pattern string. The quotes tell the DOS
  1156.             command-line processor to treat the intervening
  1157.             characters as a single argument. Without the quotes,
  1158.             DOS will think the search string is actually two
  1159.             arguments, and GREP will think that everything after
  1160.             ^ (the caret character) refers to file names, and
  1161.             will complain
  1162.  
  1163.             No files matching: *FUNCTION.*).*.
  1164.  
  1165.  
  1166.  
  1167.